#include <QDir>
#include "login.h"
#include <QtWidgets/QApplication>

QString GlobalData::platformIP = "";
int GlobalData::platformPort = 0;
QString GlobalData::fileServerIP = "";
int GlobalData::fileServerPort = 0;
QString GlobalData::username = "";
QString GlobalData::password = "";
QString GlobalData::nickname = "";
QString GlobalData::token = "";
int GlobalData::userid = 0;
int GlobalData::orgid = 0;
QString GlobalData::fsUsername = "";
QString GlobalData::fsPassword = "";
QString GlobalData::fileStorageDir = "";

int main(int argc, char *argv[]) {
	QDir* dir = new QDir;
	QString strTmp = QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation) + "/VMediax/PRA";
	if (!dir->exists(strTmp)) {
		dir->mkpath(strTmp);
	}
	QString logPath = strTmp + "/logs";
	if (!dir->exists(logPath)) {
		dir->mkpath(logPath);
	}
	QString dataPath = strTmp + "/data";
	if (!dir->exists(dataPath)) {
		dir->mkpath(dataPath);
		QFile::copy("./data/data.s3db", dataPath + "/data.s3db");
	}

	if (!Log::instance().open_log()) {
		std::cout << "Log::open_log() failed" << std::endl;
		return -1;
	}

    QApplication a(argc, argv);
	Login w;
    w.show();
    return a.exec();
}
